<?php
/**
 * 本类为图片处理
 * Created by PhpStorm.
 * User: hotpot
 * Date: 2017/8/16
 * Time: 19:41
 */

namespace app\admin\controller;


use think\Controller;
use think\Request;
use think\Image;

class Uploads extends Controller
{
    /**
     * 图像上传
     */
    public function uploads(Request $request)
    {
        $files=$request->file("files");
        if(!$files){
            $this->error("没有文件");
        }
        foreach ($files as $file){
        $info = $file->move(ROOT_PATH . 'public' . DS .'static'. DS . 'uploads');
//            再弄一个数组的单独列，为USER ALLINFO的图片截取路径
        $arr['name']=$info->getSaveName();
        if($info){
            $str=str_replace("/index.php","",$request->root());
            $arr[]=$str.'/static/uploads/'.$info->getSaveName();
        }
        else{
            $files->getError();
        }
    }
        $this->success("上传成功","",$arr);
        $this->assign("pic",$arr);
        return view();
    }

}